﻿@inherits TscComponentBase

<Gridstack Items="Panels" Id="@(ParentPanel?.Id.ToString())" Readonly="!IsEdit" Class="@($"{Class}")" ItemStyle="@("background-color:white;border: 1px solid #E1E3EA;border-radius: 12px;")">
    <ItemContent>
        @{
            var actionHeight = context.PanelType == PanelTypes.Tabs || !IsEdit ? 0 : 28;
        }
        @if (IsEdit && context.PanelType != PanelTypes.Tabs)
        {
            <div style=@($"height:{actionHeight}px;{(IsEdit?"cursor: move":"")};") class="d-flex draggable">
                <MSpacer />
                <PanelTool Value="context" ConfigurationChartPanel="ConfigurationChartPanel" RemovePanel="RemovePanel" />
            </div>
        }
        <div style="@($"height:calc(100% - {actionHeight}px);")" class="overflow-y">
            @switch (context.PanelType)
            {
                case PanelTypes.Tabs:
                    <TabsPanel Panel="context as UpsertTabsPanelDto">
                        <HeaderRightContent>
                            <PanelTool Value="context" AddPanel="AddChildPanel" RemovePanel="RemovePanel" Style="z-index:1000;" />
                        </HeaderRightContent>
                    </TabsPanel>
                    break;
                case PanelTypes.Text:
                    <TextPanel Value=context />
                    break;
                case PanelTypes.Trace:
                    <TscTrace ConfigurationRecord="ConfigurationRecord" />
                    break;
                case PanelTypes.Topology:
                    <TopologyPanel ConfigurationRecord="ConfigurationRecord" />
                    break;
                case PanelTypes.Chart or PanelTypes.Table:
                    <ChartPanel Value="context as UpsertChartPanelDto" />
                    break;
                case PanelTypes.Log:
                    <LogPanel ConfigurationRecord="ConfigurationRecord" />
                    break;
                case PanelTypes.Select:
                    if (context.Title == "ServiceError")
                    {
                        <LogError ConfigurationRecord="ConfigurationRecord" />
                        break;
                    }
                    <PanelSelect Panel="context" OnSelect="ReplacePanel" />
                    break;
                default:                   
                    break;
            }
        </div>
    </ItemContent>
</Gridstack>